/*
 * @Author: 0x9DEFA478
 * @Date: 2021-11-24 22:22:33
 * @LastEditTime: 2021-12-19 23:04:02
 * @LastEditors: 0x9DEFA478
 * @Description: 
 * QQ:2652450237
 * ============================================================================================================================================
 * 
 * 
 * 
 *                                                                                               ************      ****************************
 *                                                                                             ************      ****************************  
 *                                                                                           ************      ****************************    
 *                                                                                         ************      ****************************      
 *                                                                                       ************      ************                        
 *                                                                                     ************      ************                          
 *                                                                                   ************      ************                            
 *                                                                                 ************      ************                              
 *                                                                               ************      ************                                
 *                                                                             ************      ************                                  
 *                                                                           ************      ************                                    
 *                                                                         ************      ************                                      
 *                                                                       ************      ************                                        
 *                                                                     ************      ************                                          
 *                                                                   ************      ************                                            
 *                                                                 ************      ************                                              
 *                                                               ************      ************                                                
 *                                                             ************      ************                                                  
 *                                                           ************      ************                                                    
 *                                                         ************      ************                                                      
 *                                                       ************      ************                                                        
 *                                                     ************      ************                                                          
 *                                                   ************      ************                                                            
 *                                                 ************      ************                                                              
 *                                               ************      ************                                                                
 *                                             ************      ************                                                                  
 *                                           ************      ************                                                                    
 *                                         ************      ************                                                                      
 *                                       ************      ************                                                                        
 *                                     ************      ************                                                                          
 *                                   ************      ************                                                                            
 *                                 ************      ************                                                                              
 *                               ************      ************                                                                                
 *                             ************      ************                                                                                  
 *                           ************      ************                                                                                    
 *                         ************      ************                                                                                      
 *       ****************************      ************                                                                                        
 *     ****************************      ************                                                                                          
 *   ****************************      ************                                                                                            
 * ****************************      ************                                                                                              
 * 
 * 
 * 
 * ============================================================================================================================================
 * 
 */
#include "dma2d.h"
#include "IP_DMA2D.h"
#include "Peripherals_Instence.h"
#include "MemoryMalloc.h"


#define DMA2D_Handle_MemoryMalloc                                 MemoryMalloc_DTCM

extern void DMA2D_SetIrqCallback(void (*IP_IRQ_Callback)(void*),void* v);

void DMA2D_Init(){

  H_TS_LockLock(ip_rcc_Lock);
  RCC->AHB3ENR|=RCC_AHB3ENR_DMA2DEN;
  H_TS_LockUnlock(ip_rcc_Lock);
  

  ip_dma2d=DMA2D_Handle_MemoryMalloc.Malloc(sizeof(IP_DMA2D));
  if(cH_IsNull(ip_dma2d)){
    for(;;){
    }
  }

  DMA2D_SetIrqCallback((void (*)(void*))IP_DMA2D_IRQ,ip_dma2d);

  IP_DMA2D_Init(ip_dma2d,DMA2D);
  IP_DMA2D_SetAMTCR(ip_dma2d,0);

  HAL_NVIC_SetPriority(DMA2D_IRQn,7,0);
  HAL_NVIC_EnableIRQ(DMA2D_IRQn);

}

void DMA2D_DeInit(){

  IP_DMA2D_DeInit(ip_dma2d);
  DMA2D_Handle_MemoryMalloc.Free(ip_dma2d);
  ip_dma2d=NULL;

  H_TS_LockLock(ip_rcc_Lock);
  RCC->AHB3ENR&=~RCC_AHB3ENR_DMA2DEN;
  H_TS_LockUnlock(ip_rcc_Lock);

}





